package com.woniu.darryringmall.front.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.darryringmall.front.entity.Collect;
import com.woniu.darryringmall.front.entity.CollectVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 收藏表mapper
 */
public interface CollectMapper extends BaseMapper<Collect> {
    @Insert("insert into mall_collect(userId,remarkTime,goodsId,goodsSpecId) values(#{userId},#{remarkTime},#{goodsId},#{goodsSpecId})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    void add(Collect collect);

    @Select("select c.id,g.id gid,g.name,g.image,g.goodsNo,s.price,s.specvalues,c.remarkTime  from mall_goods g,mall_collect c,mall_goods_spec s where c.goodsId=g.id and g.id=s.goodsId and c.goodsSpecId=s.id and c.userId=#{userId}")
    List<CollectVo> getByUserId(int userId);
}
